package cn.edu.jxau.test;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 * @author Fudashi
 */
public class Main {

	public static void main(String[] args) {

		System.out.println(foo("We are students.","aeiou"));
	}

	public static String foo(String str, String remove) {

		// 1.参数校验 //
		Objects.requireNonNull(str, "参数str不能为null");
		Objects.requireNonNull(remove, "参数remove不能为null");
		if (str.length() == 0) {
			throw new IllegalArgumentException("参数str是空串");
		}

		// 2.构造remove的hash集 //
		Set<Character> set = new HashSet<>();
		for (int i = 0, end = remove.length(); i < end; i++) {
			set.add(remove.charAt(i));
		}

		// 3.根据str构造一个不含有remove中的字符的字符串 //
		StringBuilder result = new StringBuilder();
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			if (!set.contains(ch)) {
				result.append(ch);
			}
		}
		return result.toString();
	}
}
